package com.gmall.product.controller;

import com.gmall.common.result.PageInfo;
import com.gmall.common.result.Result;
import com.gmall.model.product.SpuInfo;
import com.gmall.product.service.SpuInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("admin/product/spu")
public class SpuController {

    @Autowired
    private SpuInfoService spuInfoService;
    @PostMapping("/{pageNo}/{pageSize}")
    public Result<PageInfo<SpuInfo>> selectPage(@PathVariable Integer pageNo,
                                                @PathVariable("pageSize") Integer pageSize,
                                                @RequestParam("category3Id") Long category3Id){
        //Controller
        //校验 form表单校验

        return spuInfoService.selectPage(category3Id,pageNo,pageSize);

    }

    @PostMapping("/saveSpuInfo")
    public Result<String> saveSpuInfo(@RequestBody SpuInfo spuInfo){
        return spuInfoService.saveSpuInfo(spuInfo);
    }

    @DeleteMapping("/delete/{spuId}")
    public Result<String> remove(@PathVariable Long spuId){
        return spuInfoService.remove(spuId);
    }

}
